package com.manage.file;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.fileupload.ProgressListener;

public class FileUploadListener implements ProgressListener {
	private HttpSession session;

	public FileUploadListener(HttpServletRequest request) {
		session = request.getSession();
		UploadState state = new UploadState();
		session.setAttribute("state", state);
	}

	public void update(long readedBytes, long totalBytes, int currentItem) {
		UploadState state = (UploadState) session.getAttribute("state"); 
		state.setReadedBytes(readedBytes);
		state.setTotalBytes(totalBytes);
		state.setCurrentItem(currentItem);
	}

}
